home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / OWL / OWLFILE / OWLFILE.PAS < prev    next >
Pascal/Delphi Source File  |  1994-03-28  |  2KB  |  87 lines

  1. program OWLFile;
  2.  
  3. {$R OWLFile.res}
  4.  
  5. uses WinTypes, WinProcs, OWindows, ODialogs, BWCC, Strings;
  6.  
  7. {$I OWLFile.inc}
  8.  
  9. const
  10.   MaxBuff = 128;
  11.  
  12. type
  13.  
  14.   MLApplication = object(TApplication)
  15.     procedure InitMainWindow; virtual;
  16.   end;
  17.  
  18.   PMLWindow = ^MLWindow;
  19.   MLWindow = object(TDlgWindow)
  20.     Editor : PEdit;
  21.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  22.     procedure GetWindowClass(var AWndClass: TWndClass); virtual;
  23.     procedure IDLoad(var MSG: TMessage);
  24.       virtual id_First + id_Load;
  25.     procedure IDSave(var MSG: TMessage);
  26.       virtual id_First + id_Save;
  27.   end;
  28.  
  29. constructor MLWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  30.   var
  31.     AControl : PControl;
  32.   begin
  33.     TDlgWindow.Init(AParent, ATitle);
  34.     AControl := New(PEdit, InitResource(@Self, id_Editbox, MaxBuff));
  35.     SendDlgItemMessage(HWindow, id_Editbox, em_LimitText, MaxBuff, 0);
  36.   end;
  37.  
  38. procedure MLWindow.GetWindowClass(var AWndClass: TWndClass);
  39. begin
  40.   TDlgWindow.GetWindowClass(AWndClass);
  41.   AWndClass.lpszClassName := 'bordlg';
  42. end;
  43.  
  44. procedure MLWindow.IDLoad(var MSG: TMessage);
  45.   var
  46.     FBuff : TOFStruct;
  47.     PStrngBuff : PChar;
  48.     Hand : integer;
  49.   begin
  50.     GetMem(PStrngBuff, MaxBuff);
  51.     Hand := OpenFile('TEXT.TXT', FBuff, of_Prompt OR of_Read);
  52.     _lread(Hand, PStrngBuff, MaxBuff);
  53.     SendDlgItemMessage(HWindow, id_Editbox, wm_SetText, 0,
  54.                        Longint(PStrngBuff));
  55.     _lclose(Hand);
  56.     FreeMem(PStrngBuff, MaxBuff);
  57.   end;
  58.  
  59. procedure MLWindow.IDSave(var MSG: TMessage);
  60.   var
  61.     FBuff : TOFStruct;
  62.     PStrngBuff : PChar;
  63.     Hand : integer;
  64.   begin
  65.     GetMem(PStrngBuff, MaxBuff);
  66.     Hand := OpenFile('TEXT.TXT', FBuff, of_Create OR of_Write);
  67.     SendDlgItemMessage(HWindow, id_Editbox, wm_GetText, MaxBuff,
  68.                        Longint(PStrngBuff));
  69.     _lwrite(Hand, PStrngBuff, StrLen(PStrngBuff));
  70.     _lclose(Hand);
  71.     FreeMem(PStrngBuff, MaxBuff);
  72.   end;
  73.  
  74. procedure MLApplication.InitMainWindow;
  75.   begin
  76.     MainWindow := New(PMLWindow, Init(nil, PChar(id_Dialog)))
  77.   end;
  78.  
  79. var
  80.   MLApp : MLApplication;
  81.  
  82. begin
  83.   MLApp.Init('MLDlg');
  84.   MLApp.Run;
  85.   MLApp.Done;
  86. end.
  87.